/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tenorclient;

import java.net.InetAddress;

/**
 *
 * @author Tomasz Nowak
 */
public class Contact implements IContact 
{

	private InetAddress inetAddress;
	private String name;
	private int port;
	
	public Contact(InetAddress address, int contactPort, String contactName) 
	{
		inetAddress = address;
		name = contactName;
		port = contactPort;
	}

	@Override
	public InetAddress getAddress()
	{
		return inetAddress;
	}
	
	@Override
	public String toString()
	{
		return  name + "@" + inetAddress + ":" + port;
	}

	@Override
	public String getName()
	{
		return name;
	}

	@Override
	public int getPort()
	{
		return port;
	}
	
	@Override
	public boolean equals(Object o)
	{
		IContact value = (IContact)o;
		if(value == null)
		{
			return false;
		}
		return (port == value.getPort() && 
				name.equals(value.getName()) && 
				inetAddress.equals(value.getAddress()));
	}

	@Override
	public void setName(String newName)
	{
		name = newName;
	}
}
